.PHONY: all clean

all: run final.pdf

final.pdf: report/final.tex report/ref.bib
	cd report && xelatex final.tex && bibtex final && xelatex final.tex && xelatex final.tex
	cd report && rm -rf *.aux *.bbl *.blg *.log *.out *toc

run: src/step-3.cc src/CMakeLists.txt
	cd src && mkdir build && cd build && cmake .. && make && ./step-3 > output.txt
	mv src/build/solution.vtk result/solution.vtk
	mv src/build/output.txt result/output.txt

clean:
	cd report && rm -rf *.aux *.bbl *.blg *.log *.out *toc
	cd report && rm -rf *.pdf
	cd src && rm -rf *.json && rm -rf build
	cd result && rm -rf *.txt *.vtk
	rm -rf .DS_Store
	cd src && rm -rf .DS_Store
	cd result && rm -rf .DS_Store
	cd report && rm -rf .DS_Store
